package nl.weeaboo.sh.editor.area;

import java.awt.Image;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.ListSelectionModel;

import nl.weeaboo.sh.level1.FlyingSkull;
import nl.weeaboo.sh.level1.Skull;
import nl.weeaboo.sh.model.RoomEnemyModel;
import timon.common.components.IconListCellRenderer;

@SuppressWarnings("serial")
public class EnemyBrowser extends JList {

	public EnemyBrowser() {
		setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		setCellRenderer(new IconListCellRenderer() {
			public Image getImageFor(Object object) {
				return null;
			}
			public String getLabelFor(Object object) {
				if (object instanceof RoomEnemyModel) {
					RoomEnemyModel enemy = (RoomEnemyModel)object;
					return enemy.getClassName().substring(enemy.getClassName().lastIndexOf('.')+1);
				}
				return "<html><i><font color='#555555'>Delete</font></i></html>";
			}
		});
		
		DefaultListModel model = new DefaultListModel();
		model.addElement(null);
		model.addElement(new RoomEnemyModel(Skull.class.getName()));
		model.addElement(new RoomEnemyModel(FlyingSkull.class.getName()));
		setModel(model);
	}
	
	//Functions
	
	//Getters
	public RoomEnemyModel getSelectedValue() { return (RoomEnemyModel)super.getSelectedValue(); }
	
	//Setters
	
}
